package com.du.fileload.framework;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@ComponentScan(basePackages = {"com.du"})
public class DFileLoadFrameWorkApplication  extends SpringBootServletInitializer {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application =  SpringApplication.run(DFileLoadFrameWorkApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");

        System.out.println("----------------------------------------------------------");
        System.out.println();
        System.out.println("\tApplication  is running! Access URLs:\t" );
        System.out.println();
        System.out.println("\t\tLocal访问网址: \t\thttp://localhost:" + port + path + "\n\t");
        System.out.println("\t\tExternal访问网址: \thttp://" + ip + ":" + port + path + "\n\t");
        System.out.println("----------------------------------------------------------");

    }


    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
    {
        return application.sources(DFileLoadFrameWorkApplication.class);
    }


}
